package com.cskaoyan.service.impl;

import com.cskaoyan.bean.*;
import com.cskaoyan.mapper.LogMapper;
import com.cskaoyan.service.LogService;
import com.cskaoyan.utils.CommonUtil;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @PROJECT_NAME: market_34th
 * @DESCRIPTION:
 * @Author: qiu
 * @DATE: 2021/10/19 21:36
 */
@Service
public class LogServiceImpl implements LogService {

    @Autowired
    LogMapper logMapper;

    @Override
    public BasePageData<Log> list(String name, BaseParam param) {

        // 配置分页信息
        PageHelper.startPage(param.getPage(), param.getLimit());
        // 构造条件的对象
        LogExample example = new LogExample();
        LogExample.Criteria criteria = example.createCriteria();
        if (CommonUtil.isStrNotEmpty(name)) {
            criteria.andAdminLike("%" + name + "%");
        }
        // 设置排序
        example.setOrderByClause(param.getSort() + " " + param.getOrder());
        List<Log> logs = logMapper.selectByExample(example);

        return BasePageData.ok(logs);

    }
}
